package com.geeklan.smart.ui.viewmodel.common;

import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.geeklan.smart.data.repository.msg.CommonRepository;

public class CommonViewModelFactory implements ViewModelProvider.Factory {

    private final CommonRepository msgRepository;

    public CommonViewModelFactory(CommonRepository msgRepository) {
        this.msgRepository = msgRepository;
    }

    @Override
    public <T extends ViewModel> T create(Class<T> modelClass) {
        if (modelClass.isAssignableFrom(CommonViewModel.class)) {
            return (T) new CommonViewModel(msgRepository);
        }
        throw new IllegalArgumentException("Unknown ViewModel class");
    }
}

